What is the CSS property to specify the space between the content of an element and its border?
What is the CSS property to specify the space between the content of an element and its border?
14406-Jun-2023
Updated on 07-Jun-2023
Home / DeveloperSection / Forums / What is the CSS property to specify the space between the content of an element and its border?
What is the CSS property to specify the space between the content of an element and its border?
Aryan Kumar
07-Jun-2023The CSS property to specify the space between the content of an element and its border is padding. The padding property can be used to add space to all four sides of an element, or to specific sides of an element.
The padding property is a shorthand property for the following properties:
For example, the following CSS code will add 10 pixels of padding to all four sides of an element:
Code snippet
The following CSS code will add 10 pixels of padding to the top and bottom of an element, and 20 pixels of padding to the left and right of an element:
Code snippet
The padding property can also be used to add different amounts of padding to different sides of an element. For example, the following CSS code will add 10 pixels of padding to the top and bottom of an element, and 20 pixels of padding to the left and right of an element:
Code snippet
The padding property can be used to create a variety of effects, such as adding a border around an element, or creating a space between the content of an element and its border.
Here are some additional tips for using the padding property:
By following these tips, you can use the padding property to create a variety of effects in your CSS code.